package com.game.backend.controller.user.account;

import com.game.backend.common.ResponseEntity;
import com.game.backend.entity.RegisterReq;
import com.game.backend.service.user.account.RegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/user/account")
public class RegisterController {
    @Autowired
    private RegisterService registerService;

    @RequestMapping("/register")
    public ResponseEntity register(@RequestBody RegisterReq req){
        registerService.register(req.getUsername(),req.getPassword(),req.getConfirmedPassword());
        return new ResponseEntity();
    }

    @RequestMapping("/check_username")
    public ResponseEntity checkUsername(String username){
        String message = registerService.checkUsername(username);
        return new ResponseEntity().setMessage(message);
    }
}
